// DlgIWeldColumn.cpp : implementation file
//

#include "stdafx.h"
#include "pdarx.h"
#include "DlgIWeldColumn.h"
#include "uelisp/pipinit.h"
#include "UeItem.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

static double width_list[] =
{	
	200, 
	250, 
	300,
	350,
	400,
	450,
	500,
	550,
	600,
	650,
	700,
	750,
	800,
	850,
	900,
	950,
	1000,
	1050,
	1100,
	1150,
	1200,
	1250,
	1300,
	1350,
	1400,
	1450,
	1500,
	1550,
	1600,
	1650,
	1700,
	1750,
	1800,
	1850,
	1900,
	1950,
	2000,
	2100,
	2200,
	2300,
	2400,
	2500,
	2600,
	2700,
	2800,
	2900,
	3000
};
/////////////////////////////////////////////////////////////////////////////
// CDlgIWeldColumn dialog


CDlgIWeldColumn::CDlgIWeldColumn(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIWeldColumn::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIWeldColumn)
	m_dAngle = 0.0;
	m_dMinThick = 0.0;
	m_dOffsetX = 0.0;
	m_dOffsetY = 0.0;
	m_dThick = 0.0;
	m_dWidth = 0.0;
	//}}AFX_DATA_INIT
	::AfxSetResourceHandle(g_ARXInstance);
}


void CDlgIWeldColumn::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgIWeldColumn)
	DDX_Control(pDX, IDC_LIST_WIDTH, m_lstWidth);
	DDX_Control(pDX, IDC_LIST_THICK, m_lstThick);
	DDX_Text(pDX, IDC_EDIT_COLUMN_ANGLE, m_dAngle);
	DDX_Text(pDX, IDC_EDIT_COLUMN_MIN_THICK, m_dMinThick);
	DDX_Text(pDX, IDC_EDIT_COLUMN_OFFSET_X, m_dOffsetX);
	DDX_Text(pDX, IDC_EDIT_COLUMN_OFFSET_Y, m_dOffsetY);
	DDX_Text(pDX, IDC_EDIT_COLUMN_THICK, m_dThick);
	DDX_Text(pDX, IDC_EDIT_COLUMN_WIDTH, m_dWidth);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgIWeldColumn, CDialog)
	//{{AFX_MSG_MAP(CDlgIWeldColumn)
	ON_LBN_SELCHANGE(IDC_LIST_WIDTH, OnSelchangeListWidth)
	ON_LBN_SELCHANGE(IDC_LIST_THICK, OnSelchangeListThick)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgIWeldColumn message handlers

CUeList CDlgIWeldColumn::GetColumnValue()
{
	CUeList rtList;

	rtList.AddHead(CUeItem(m_dWidth));
	rtList.AddHead(CUeItem(m_dThick));
	rtList.AddHead(CUeItem(m_dMinThick));

	rtList.AddHead(CUeItem(m_dAngle));
	rtList.AddHead(CUeItem(m_dOffsetX));
	rtList.AddHead(CUeItem(m_dOffsetY));
	
	return rtList.reverse();

}

void CDlgIWeldColumn::OnSelchangeListWidth() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	int nSel = m_lstWidth.GetCurSel();
	m_dWidth = width_list[nSel];
	UpdateData(FALSE);	
}

void CDlgIWeldColumn::OnSelchangeListThick() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	int nSel = m_lstThick.GetCurSel();
	m_dThick = width_list[nSel];
	UpdateData(FALSE);	
}

BOOL CDlgIWeldColumn::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString strTmp;
	for (int i = 0; i < sizeof(width_list) / sizeof(double); i++)
	{
		strTmp.Format(_T("%.0f"),width_list[i]);
		m_lstThick.AddString(strTmp);
		m_lstWidth.AddString(strTmp);
	}

	m_dThick = width_list[0];
	m_dWidth = width_list[0];
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

int CDlgIWeldColumn::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	::AfxSetResourceHandle(g_CADInstance);
	
	return 0;
}
